﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test2_24Jan
{
    class Vector
    {
        private int[] arrayInt;
        private int firstIndex;

        public Vector(int size, int firstIndex)
        {
            arrayInt = new int[size];
            this.firstIndex = firstIndex;
        }

        public int this [int index]
        {
            set
            {
                if (Success(index))
                {
                    arrayInt[index - firstIndex] = value;
                }
                else
                    Console.WriteLine("Erorr");
            }
            get { return arrayInt[index-firstIndex]; }
        }

        private bool Success(int index)
        {
            if (index - firstIndex >= 0 && index - firstIndex < arrayInt.Length)
                return true;
            else return false;
        }
        
        public void ShowArray()
        {
            foreach (var item in arrayInt)
            {
                Console.Write(item + " ");
            }
        }
        public int[] GetArray()
        {
            return arrayInt;
        }

        public static void SumArrays(int[] a, int[] b)
        {
            int[] c;
            if (a.Length >= b.Length)
            {
                c = new int[a.Length];
                for (int i = 0; i < a.Length; i++)
                {
                    if (i < b.Length)
                        c[i] = a[i] + b[i];
                    else
                        c[i] = a[i];
                }
                foreach (var item in c)
                {
                    Console.Write(item + " ");
                }
            }
            if (b.Length > a.Length)
            {
                c = new int[b.Length];
                for (int i = 0; i < b.Length; i++)
                {
                    if (i < a.Length)
                        c[i] = a[i] + b[i];
                    else
                        c[i] = b[i];
                }
                foreach (var item in c)
                {
                    Console.Write(item + " ");
                }
            }
        }
    }
}
